<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增医生管理')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-doctor-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">姓名：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input id="userId" name="userId" type="hidden" th:value="${userId}"/>
                    <input id="doctorName" name="doctorName" type="hidden" th:value="${doctorName}"/>
                    <input class="form-control" type="text" onclick="selectUserIdRadio()" id="userName"
                           readonly="true" th:value="${userName}"  required>
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">所属科室：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input id="departmentId" name="departmentId" type="hidden" th:value="${departmentId}"/>
                    <input class="form-control" type="text" onclick="selectDepartmentIdRadio()" id="departmentName"
                           readonly="true" th:value="${departmentName}" required>
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">挂号类型：</label>
            <div class="col-sm-8">
                <select name="registrationType" class="form-control m-b"
                        th:with="type=${@dict.getType('hospital_register_type')}" required>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">医师类型：</label>
            <div class="col-sm-8">
                <select name="type" class="form-control m-b" th:with="type=${@dict.getType('hospital_doctor_type')}"
                        required>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('sys_user_status')}">
                    <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}"
                           th:checked="${dict.default}">
                    <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "hospital/doctor"
    var deptPrefix = ctx+"hospital/department"
    var userPrefix =  ctx + "system/user";
    $("#form-doctor-add").validate({
        focusCleanup: true
    });


    function selectUserIdRadio(){
        var options = {
            title: '选择用户',
            url: userPrefix+"/selectUser",
            callBack: doUserSubmit
        };
        $.modal.openOptions(options);
    }


    function doUserSubmit(index,layer){
        var body = $.modal.getChildFrame(index);
        $("#userId").val(body.find("#userId").val());
        $("#doctorName").val(body.find("#userName").val());
        $("#userName").val(body.find("#userName").val());
        $.modal.close(index);
    }

    function selectDepartmentIdRadio(){
        var options = {
            title: '选择用户',
            url: deptPrefix+"/selectDepartment",
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }


    function doSubmit(index,layer){
        var body = $.modal.getChildFrame(index);
        $("#departmentId").val(body.find("#departmentId").val());
        $("#departmentName").val(body.find("#departmentName").val());
        $.modal.close(index);
    }

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-doctor-add').serialize());
        }
    }
</script>
</body>
</html>